
<#include
        "../common/com.html"  /> <@layout>
<head>
    <!-- page specific plugin styles -->
    <!-- ace styles -->
    <script src="${ctx}/static/inc/platform/js/ajax.js"></script>
    <link rel="stylesheet" type="text/css" href="${ctx}/static/cbb/artDialog/skins/blue.css">
    <script src="${ctx}/static/cbb/artDialog/jquery.artDialog.js"></script>
</head>
<script type="text/javascript">


    /**
     *
     */
    function dels(obj,yxbz){
        var url = '${ctx}/hyglXf/delete/';
        $("#id").attr("value",obj);
        $('#myform').form('submit', {
            url : url,
            onSubmit : function() {
            },
            success : function(data) {
                // 鍥炲～椤甸潰
                alert(data);
                window.location.reload();
            }
        });
    }

</script>
<body>

<div class="page-content">
    <div class="row-fluid">
        <div class="span12">
            <form class="form-inline" id="myform">
                <input type="hidden" name="id" id="id">

                <button id="search_btn" onclick="return false;" class="btn btn-info btn-small"  onclick="queryModel()">
                    查询
                </button>

            </form>
            <!-- PAGE CONTENT BEGINS -->
            <table id="grid-table"></table>
            <div id="grid-pager"></div>
            <!-- PAGE CONTENT ENDS -->
        </div><!-- /.span -->
    </div><!-- /.row-fluid -->
</div><!-- /.page-content -->
<!-- page specific plugin scripts -->


<#include  "../common/end.html"  />
<script>

    /**
     * 缂栬緫閫変腑鐨勬ā鍨嬩俊鎭�
     */
    function edits(obj){
        var rowData = $("#grid-table").getRowData(obj);
        var  url = '${ctx}/hyglXf/newModes?id=' + rowData.id;
        initArtDialog({url:url, title:'修改', width:730, height:330,lock:true,background: '#EAEAEA'});
    }
</script>
<script type="text/javascript">

    $("#search_btn").click(function(){

        // var start=$("#start").val();

        $("#grid-table").jqGrid('setGridParam',{
            datatype:'json',
            postData:{  }, //鍙戦�鏁版嵁 'search_LIKE_lrrq':start
            page:1
        }).trigger("reloadGrid");
    });


    jQuery(function($) {

        //  jqgrid
        var grid_selector = "#grid-table";
        var pager_selector = "#grid-pager";
        var start=$("#start").val();


        jQuery(grid_selector).jqGrid({
            datatype: "json", //灏嗚繖閲屾敼涓轰娇鐢↗SON鏁版嵁
            mtype:"POST",
            postData:{}, //鍙戦�鏁版嵁
            url:'${ctx}/hyglXf/query',
            height: '55%',
            footerrow:false,  //鍚堣鏁版嵁
            colNames:['操作 ',
                '卡号',   '消费名称',  '消费数量',  '消费金额',  '消费折扣',  '消费实际金额',  '录入人代码',    '0 未结账', ''],
            colModel:[
                {name:'edits',index:'',width:80,sortable:false, resizable:true,formatter: printthis},
                {name:'card', width:100,sortable:false},
                {name:'xfmc', width:100,sortable:false},
                {name:'xfsl', width:100,sortable:false},
                {name:'xfje', width:100,sortable:false},
                {name:'xfzk', width:100,sortable:false},
                {name:'xfsjjg', width:100,sortable:false},
                {name:'lrrydm', width:100,sortable:false},
                {name:'yxbz', width:100,sortable:false,formatter:'select', editoptions:{value:"0:未结账;1:已结账;"}},
                {name:'id',index:'',width:50,sortable:false,hidden:true}
            ],
            rownumbers:true,//娣诲姞宸︿晶琛屽彿
            sortname: 'id',
            sortable: false,
            viewrecords: true, //鏄惁鏄剧ず琛屾暟
            rowNum:20,
            rowList:[10,20,30],
            loadtext: '正在加载数据...',
            loadui : 'block',
            pager : pager_selector,
            altRows: true,
            shrinkToFit: true,
            //toppager: true,
//
//        multiselect: true,
//        //multikey: "ctrlKey",
//        multiboxonly: true,

            loadComplete : function() {
                var table = this;
                setTimeout(function(){
                            updatePagerIcons(table);
                        },
                        0);
            } ,
            //           ondblClickRow: openview,
//
            caption: " <input type='button' onclick='add()'  class='btn btn-mini btn-danger' value='鏂板'> " ,
            autowidth: true
        });
        //鎸夐挳
        function printthis(cellvalue,options,rowObject){
            var ids=rowObject.id;
            var yxbz =rowObject.spbz;
            var buttomHtml= "<a class='btn btn-mini btn-success' href=\"javascript:edits('" + ids + "','" + yxbz + "')\" title='结账'>结账</a> &nbsp;" +
                    "<a class='btn btn-mini btn-danger' href=\"javascript:dels('" + ids + "','" + yxbz + "')\" title='取消'>取消</a> </div> ";

//            var buttomHtml="<a href='#' class='btn btn-primary btn-mini ' onclick='opennew()'><i class='icon-print  bigger-125  '>鎵撳嵃</i>  </a>";
            return buttomHtml
        }




    });




    //replace icons with FontAwesome icons like above
    function updatePagerIcons(table) {
        var replacement =
        {
            'ui-icon-seek-first' : 'icon-double-angle-left bigger-150',
            'ui-icon-seek-prev' : 'icon-angle-left bigger-150',
            'ui-icon-seek-next' : 'icon-angle-right bigger-150',
            'ui-icon-seek-end' : 'icon-double-angle-right bigger-150'
        };
        $('.ui-pg-table:not(.navtable) > tbody > tr > .ui-pg-button > .ui-icon').each(function(){
            var icon = $(this);
            var $class = $.trim(icon.attr('class').replace('ui-icon', ''));

            if($class in replacement) icon.attr('class', 'ui-icon '+replacement[$class]);
        })
    }

    function enableTooltips(table) {
        $('.navtable .ui-pg-button').tooltip({container:'body'});
        $(table).find('.ui-pg-div').tooltip({container:'body'});
    }

    //var selr = jQuery(grid_selector).jqGrid('getGridParam','selrow');

    //    $( "#adds" ).on('click', function(e) {
    //        e.preventDefault();
    //        addr();
    //    });


    window.onresize = function  _doResize() {
        var ss = pageSize();
        $("#grid-table").jqGrid('setGridWidth', ss.WinW-10).jqGrid('setGridHeight', ss.WinH-200);
    }

    function pageSize() {
        var winW, winH;
        if(window.innerHeight) {// all except IE
            winW = window.innerWidth;
            winH = window.innerHeight;
        } else if (document.documentElement && document.documentElement.clientHeight) {// IE 6 Strict Mode
            winW = document.documentElement.clientWidth;
            winH = document.documentElement.clientHeight;
        } else if (document.body) { // other
            winW = document.body.clientWidth;
            winH = document.body.clientHeight;
        }  // for small pages with total size less then the viewport
        return {WinW:winW, WinH:winH};
    }




</script>

</body>
</@layout>
